import { SerializeClass, Serialize, CSMemberType } from "../../../../core/serialize";
import { UniData, UniqueObjectConfig } from "../../../../core/unique_class";
import { KSelection, KSelectionConfig } from "./k_selection";
import { Karma, KarmaConfig } from "./karma";

@SerializeClass("KEventConfig")
export class KEventConfig extends KarmaConfig {
    @Serialize(KSelectionConfig, CSMemberType.Array)
    selections: KSelectionConfig[] = [];
};

@SerializeClass("KEvent")
export class KEvent extends Karma {
    config: KEventConfig;
    data: UniData<KEventConfig>;

    selections: KSelection[] = [];
    onInit(): void {
        this.data.selections.forEach(kSelConf => {
            let kSel = new KSelection();
            UniqueObjectConfig.AssignUniqueObject(kSel, kSelConf);
            this.selections.push(kSel);
            kSel.kEvt = this;
        });
    }
};